package hu.person.util;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
 * @Classname ResponseUtils
 * @Description TODO
 * @Date 2025/11/5 23:54
 * @Created by 24562
 */

public final class ResponseUtils {

    public static <T> ResponseResult<T> sucess(T data) {
        ResponseResult<T> result = new ResponseResult<>();
        result.setCode(200);
        result.setMsgCn("成功");
        result.setMsgEn("success");
        result.setData(data);
        return result;
    }

    public static <T> ResponseResult<T> failed(T data) {
        ResponseResult<T> result = new ResponseResult<>();
        result.setCode(400);
        result.setMsgCn("失败");
        result.setMsgEn("failed");
        result.setData(data);
        return result;
    }

    private ResponseUtils() {
        throw new UnsupportedOperationException("工具类不允许实例化");
    }

    @NoArgsConstructor
    @AllArgsConstructor
    @Data
    public static class ResponseResult<T>{
        private Integer code = 200;
        private String msgEn = "success";
        private String msgCn = "成功";
        private T data;
    }

}
